package test.org.offsync.util

import org.junit.runner.RunWith
import org.offsync.util.Never
import org.offsync.util.Time
import org.offsync.util.Window
import org.specs.SpecificationWithJUnit
import org.specs.runner._
import org.specs._

@RunWith(classOf[JUnitSuiteRunner])
class SpecTime extends SpecificationWithJUnit("test.org.offsync.util.SpecTime") {
  "Array(0, 1, 2, 3)" in {
    val time1: Time = Time.now
    Thread.sleep(10)
    val time2: Time = Time.now
    val time3: Time = Time.atNanos(time2.nanoseconds)
    (time1 < time2) must_== true
    (time1 <= time2) must_== true
    (time1 == time2) must_== false
    (time1 >= time2) must_== false
    (time1 > time2) must_== false

    (time2 < time1) must_== false
    (time2 <= time1) must_== false
    (time2 == time1) must_== false
    (time2 >= time1) must_== true
    (time2 > time1) must_== true

    (time1 < Never) must_== true
    (time1 <= Never) must_== true
    (time1 == Never) must_== false
    (time1 >= Never) must_== false
    (time1 > Never) must_== false
    
    (time2 < time3) must_== false
    (time2 <= time3) must_== true
    (time2 == time3) must_== true
    (time2 >= time3) must_== true
    (time2 > time3) must_== false

    (Never < time1) must_== false
    (Never <= time1) must_== false
    (Never == time1) must_== false
    (Never >= time1) must_== true
    (Never > time1) must_== true
  }
}
